package com.start_eternity.oasissafewalk.mapper;

import com.start_eternity.oasissafewalk.pojo.Driver;
import com.start_eternity.oasissafewalk.pojo.Notice;
import com.start_eternity.oasissafewalk.pojo.Order;
import com.start_eternity.oasissafewalk.pojo.Parent;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface DriverMapper {

    //司机信息的查询
    public List<Driver> list(String driverName, Short gender,
                             LocalDate begin, LocalDate end);
    /*批量删除*/
    void delete(List<Integer> ids);
    /*新增司机*/
    @Insert("insert into driver(driver_name, gender,phone,driver_license,urgent," +
            "urgent_phone,status,card_front,card_back,entry_time, update_time,delete_time,car_id,openId)" +
            " VALUES (#{driverName},#{gender},#{phone},#{driverLicense}," +
            "#{urgent},#{urgentPhone},#{status},#{cardFront},#{cardBack},#{entryTime},#{updateTime},#{deleteTime},#{carId},#{openId})")
    int insert(Driver driver);
    /*根据id查询员工*/
    @Select("select * from driver where driver_id=#{driverId}")
    Driver getById(Integer driverId);
    /*更新员工信息*/
    void update(Driver driver);
    //  查询家长关联的学生信息
    public List<Driver> queryListByPId(@Param("driverId") Integer driverId);

    //查询是否 存在该 openId 的用户
    @Select("select * from `driver` where openId = #{openId}")
    public Driver selOpenId(@Param("openId") String openId);

    /*查询信息*/
    List<Driver> getMessageById(@Param("driverId") Integer driverId);

    @Insert("insert into `notice`(`n_title`, `n_content`, n_publishTime, update_time)" +
            " VALUES (#{nTitle},#{nContent},#{nPublishtime},#{updateTime})")
    int addNotice(Notice notice);

}
